//
//  CAUpgradeTableViewCell.m
//  LNH
//
//  Created by twentylx on 2018/2/12.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAUpgradeTableViewCell.h"

@implementation CAUpgradeTableViewCell

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.bgImageView];
        [self addSubview:self.titleView];
        [self.titleView addSubview:self.leftView];
        [self.titleView addSubview:self.nameLabel];
        [self.titleView addSubview:self.rightView];
        
        [_bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self);
            make.top.equalTo(self).offset(20);
            make.bottom.equalTo(self).offset(-20);
        }];
        
        [_titleView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.bgImageView);
            make.width.mas_equalTo(300);
            make.height.mas_equalTo(60);
        }];
        
        [_leftView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleView);
            make.centerY.equalTo(self.titleView);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(ONE_PIXEL);
        }];
        
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.titleView);
            make.width.mas_equalTo(100);
        }];
        
        [_rightView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.titleView);
            make.centerY.equalTo(self.titleView);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(ONE_PIXEL);
        }];
    }
    return self;
}

#pragma mark get & set
- (UIImageView *)bgImageView {
    if (!_bgImageView) {
        _bgImageView = [UIImageView new];
        _bgImageView.image = LMImageNamed(@"yue_bg");
    }
    return _bgImageView;
}

- (UIView *)titleView {
    if (!_titleView) {
        _titleView = [UIView new];
        _titleView.backgroundColor = RGBCOLOR(254, 247, 244);
    }
    return _titleView;
}

- (UIView *)leftView {
    if (!_leftView) {
        _leftView = [UIView new];
        _leftView.backgroundColor = RGBCOLOR(244, 175, 143);
    }
    return _leftView;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.text = @"代言人";
        _nameLabel.textColor = RGBCOLOR(233, 85, 19);
        _nameLabel.textAlignment = NSTextAlignmentCenter;
        _nameLabel.font = [UIFont systemFontOfSize:20];
    }
    return _nameLabel;
}

- (UIView *)rightView {
    if (!_rightView) {
        _rightView = [UIView new];
        _rightView.backgroundColor = RGBCOLOR(244, 175, 143);
    }
    return _rightView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
